package com.module.businessLog;

import java.util.Map;
import java.util.UUID;

import base.util.ConstantUnit;
import base.util.ResolveUnit;

import com.activityClient.client.ActivityThread;
import com.module.businessLog.vo.BeanUtil;


public class BusinessSocketClient {
	public final static String B_ID="businessLog";
	/**
	 * 组装json报文
	 * @param map 对象
	 * @return json报文字符串
	 * @throws Exception
	 */
	public static String getJson(Map<String,Object> map) throws Exception{
	    map.put(ConstantUnit.STATUS_NAME, ConstantUnit.REQUST_STATUS);
	    map.put(ConstantUnit.B_ID, B_ID);	    
	    String json = ResolveUnit.getJsonStr(map);
	    return json;
	 }
	 public static BeanUtil returnValue(Map<String,Object> map) throws Exception{
		 String sid = UUID.randomUUID().toString();
		 map.put(ConstantUnit.S_ID,sid);
			String message = getJson(map);
			ActivityThread tc = ActivityThread.getInstance();
			String receiveMessage = null;
			try {
				receiveMessage = tc.sendAndReceive(message, sid);
				BeanUtil beanUnit = ResolveUnit.resolve(receiveMessage, BeanUtil.class);
				return beanUnit;
			} catch (Exception e) {
				throw e;
			}
			
	 }
}
